const { verifyToken } = require('../utils/jwt')
const logger = require("../utils/log4js");
const { wsSend } = require('../utils/utils')

module.exports = (ws, params, online) => {
    const { userIds, msg } = params
    logger.info('/sendMsg', online.map(it => it.userInfo.name))
    let _online = online.find(item => userIds.some(userId => userId === item.userInfo._id))

    if (_online) {
        logger.info('online', 'true')
        // 在线
        wsSend(_online.ws, '/sendMsg', {
            code: 1,
            data: msg
        })
    }
}